package com.jimmyhsu.nestedscrolldemo;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.jimmyhsu.nestedscrolldemo.fragment.DemoFragment;
import com.jimmyhsu.nestedscrolldemo.view.StickyNavLayout;

import butterknife.BindView;
import butterknife.ButterKnife;

public class NestedScrolling extends AppCompatActivity {

    @BindView(R.id.id_indicator)
    TabLayout mIndicator;
    @BindView(R.id.id_pager)
    ViewPager mPager;
    @BindView(R.id.activity_main)
    StickyNavLayout mContainer;
    private Fragment[] mFragments = new DemoFragment[]{new DemoFragment(), new DemoFragment(), new DemoFragment()};
    private String[] mTitles = new String[]{"title 1", "title 2", "title 3"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_nested_scrolling);
        ButterKnife.bind(this);
        mPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return mFragments[position];
            }

            @Override
            public int getCount() {
                return mFragments.length;
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return mTitles[position];
            }
        });
        mIndicator.setupWithViewPager(mPager);
    }

}
